package com.kwok.elasticsearch.entity;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;

import java.util.Date;

@Data
@Accessors(chain = true)
@Document(indexName = "goods_index")
@Setting(shards = 5, replicas = 0)
public class Goods {

    @Id
    private Integer id;

    //@Field(type = FieldType.Text, analyzer = "ik_max_word")
    @MultiField(
            mainField = @Field(type = FieldType.Text, analyzer = "ik_max_word"),
            otherFields = {
                    @InnerField(suffix = "pinyin", type = FieldType.Text, analyzer = "pinyin")
                    //@InnerField(suffix = "keyword", type = FieldType.Keyword)
            }
    )
    private String goodsName;

    @Field(type = FieldType.Double)
    private Double price;

    @Field(type= FieldType.Text, analyzer = "ik_max_word")
    private String goodsInfo;

    @Field(type = FieldType.Keyword)
    private String image;

    //@Field(type = FieldType.Date, format = DateFormat.date_time)
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

}
